package com.unitech.drink.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 饮品分类信息
 */
@AllArgsConstructor
@Getter
public enum CategoryType {

    UNKNOWN(0, "未分组"),
    COFFEE(1, "找拿铁"),
    TEA(2, "找好茶"),
    MILKY_TEA(3, "找奶茶");

    // 对应数据库中的category_id
    private Integer code;
    private String description;

    public static CategoryType convert(Integer code) {
        return Stream.of(values())
                .filter(e -> e.code.compareTo(code) == 0)
                .findFirst()
                .orElse(UNKNOWN);
    }
}
